

const Koa = require('koa')
const app = new Koa()


const server = require('http').Server(app.callback())
const io = require('socket.io')(server, { cors: true })

const moment = require('moment')

const { querywarehouse } = require('./qplwmsApi')



io.on('connection', socket => {
    console.log(`${moment().format('YYYY-MM-DD HH:mm:ss')}-socket.io-连接成功！`)
    socket.on('send', data => {
        let startdate = moment()
        let startTime = startdate.valueOf()
        socket.emit('outputmsg', `开始时间：${startdate.format('YYYY-MM-DD HH:mm:ss')}`)
        querywarehouse(data, socket, startTime)
    })
})

module.exports = { app, server, io }